package com.team.employment.web.admin.controller.communal;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.team.employment.common.result.Result;
import com.team.employment.model.entity.BenefitInfo;
import com.team.employment.model.entity.PositionInfo;
import com.team.employment.web.admin.custom.check.IdIsEmptyCheck;
import com.team.employment.web.admin.service.BenefitInfoService;
import com.team.employment.web.admin.vo.BenefitDetailVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "福利信息管理")
@RestController
@RequestMapping("/admin/benefitInfo")
public class BenefitInfoController {

    @Autowired
    private BenefitInfoService benefitInfoService;

    @Autowired
    private IdIsEmptyCheck idIsEmptyCheck;

    @Operation(summary = "返回所有福利列表")
    @GetMapping("getBenefitInfo")
    public Result<List<BenefitInfo>> getBenefitDetailVo(){
        List<BenefitInfo> list = benefitInfoService.list();
        return Result.ok(list);
    }


    @Operation(summary = "保存或更新福利信息")
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody  BenefitInfo benefitInfo) {
        //保存的时候要判断，是管理员身份的话，status为1；以企业身份登录时，status为0，需要管理员审核；在这里先已管理员身份进行；
        benefitInfoService.saveOrUpdate(benefitInfo);
        return Result.ok();
    }

    @Operation(summary = "删除福利信息")
    @DeleteMapping("removeById/{id}")
    public Result removeById(@PathVariable Long id ) {
        idIsEmptyCheck.idIsEmpty(benefitInfoService,id);
        benefitInfoService.removeById(id);
        return Result.ok();


    }


}
